package com.zhuchang.self_rpc.test.democoding;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * @Author RenPu
 * @Date 2022/2/7 17:09
 * @Version 1.0
 * @Description: 使用 Channel的transferForm 完成图片拷贝
 **/
public class PictureCopy {

    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream = new FileInputStream("C:\\Users\\12795\\Desktop\\test.jpg");
        FileOutputStream fileOutputStream = new FileOutputStream("C:\\Users\\12795\\Desktop\\test2.jpg");


        FileChannel channel = fileInputStream.getChannel();
        FileChannel channel1 = fileOutputStream.getChannel();

        channel1.transferFrom(channel,0,channel.size());

        channel.close();
        channel1.close();

        fileInputStream.close();
        fileOutputStream.close();


    }

}
